# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=fribidi
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.19.7
pkgrel=1
pkgdesc="A Free Implementation of the Unicode Bidirectional Algorithm (mingw-w64)"
arch=('any')
license=('LGPL')
url="http://fribidi.org"
depends=("${MINGW_PACKAGE_PREFIX}-glib2")
options=('strip' '!libtool' 'staticlibs')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
source=("http://fribidi.org/download/${_realname}-${pkgver}.tar.bz2"
        "0001-No-need-to-specialcase-export-symbols-for-OS_WIN32.patch"
        "0003-fix-eols-in-tests-on.mingw.patch")
sha256sums=('08222a6212bbc2276a2d55c3bf370109ae4a35b689acbc66571ad2a670595a8e'
            '85eedcd4870140ebc419ad35c4e22214be8a96490c2af9c41738a505a0857724'
            '51b6729ea94b3dd3a8f8418733a39cde7a17888de6a407905509d8c968eff6cd')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-No-need-to-specialcase-export-symbols-for-OS_WIN32.patch
  patch -p1 -i ${srcdir}/0003-fix-eols-in-tests-on.mingw.patch
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-static \
    --with-glib

  make
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
}
